export function moneyFormat (value) {
  let unit = '';
  let limit = 10000,
    sizes = ['', '万', '亿', '万亿'],
    i;
  if (value < limit) {
    return value
  } else {
    i = Math.floor(Math.log(value) / Math.log(limit));
    value = ((value / Math.pow(limit, i)))
    unit = sizes[i];
  }
  value = parseFloat((value * 100) / 100).toFixed(4)
  let val = value.substring(0, value.length - 2)
  return val + unit;
}

export function numberFormat (value) {
  let unit = '';
  let limit = 10000,
    sizes = ['', '万', '亿', '万亿'],
    i;
  if (value < limit) {
    return value
  } else {
    i = Math.floor(Math.log(value) / Math.log(limit));
    value = ((value / Math.pow(limit, i))).toFixed(2)
    unit = sizes[i];
  }
  return value + unit;
}


export default { moneyFormat, numberFormat }